﻿using System;
using Infrastructure.Interfaces;
using MVVMBasicRIALibrary.Web.Services;
using System.ServiceModel.DomainServices.Client;

namespace MVVMBasicRIALibrary
{
    public class BasicUnitOfWork : IUnitOfWork, IDisposable
    {
        public DomainContext Context { get; private set; }

        public BasicUnitOfWork(DomainContext context)
        {
            Context = context;
            // ewentualnie przeniesc ta linie do Services.BasicDomainService
            //context.ContextOptions.DeferredLoadingEnabled = true;
        }

        public void Commit()
        {
            Context.SubmitChanges();
        }

        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
    }
}
